<!--
author:        hejiyang <silentmanager@163.com>
date:          2024-11-08 18:46:05
component:     classGroup
Copyright © YourCompanyName All rights reserved
-->
<template>
  <el-table v-loading="loading" :data="list" style="width: 100%">
    <el-table-column label="序号" width="80">
      <template #default="scope">
        {{ scope.$index + 1 + (queryParams.pageNo - 1) * queryParams.pageSize }}
      </template>
    </el-table-column>
    <el-table-column label="名称" prop="name" />
    <el-table-column label="普通客户数量" prop="base" />
    <el-table-column label="核心客户数量" prop="core" />
    <el-table-column label="大客户数量" prop="big" />
    <el-table-column label="沉默核心客户数量" prop="silence" />
    <el-table-column label="退件客户数量" prop="chargeback" />
    <el-table-column label="黑名单客户数量" prop="blacklist" />
  </el-table>
  <!-- 分页 -->
  <Pagination
    :total="total"
    v-model:page="queryParams.pageNo"
    v-model:limit="queryParams.pageSize"
    @pagination="getList"
  />
</template>

<script lang="ts" setup>
import { repurchaseStatistics } from '@/api/return-purchase'

// --------------------  表格  ---------------------
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
// 分页
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10
})

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await repurchaseStatistics({
      ...queryParams,
      queryByDept: 1
    })
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 初始化 */
onMounted(() => {
  getList()
})
</script>
